import { WxOpenDataCommands, WxOpenDataKeys } from "./WxOpenDataConsts";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    onLoad () {
        wx.onMessage(data => {
            if(data["action"] == WxOpenDataCommands.FetchFriendData)
            {
                console.log("getWxFriendCloudStorage");
                wx.getFriendCloudStorage({
                    keyList:[WxOpenDataKeys.Grade],
                    success(res)
                    {
                        console.log("friendInfoLen: " + res.data.length);
                        for(let friendInfo in res.data)
                        {
                            console.log(friendInfo.nickname + " " + friendInfo.avatarUrl + " " + friendInfo.openid);
                        }
                    },
                    fail(res)
                    {
                        console.log("fail: " + res);
                    },
                });
            }
        });
    }
}
